namespace TerritoryGame.Domain.ValueObjects;

public record PlayerColor(string Value)
{
    public static PlayerColor Red => new("#FF0000");
    public static PlayerColor Blue => new("#0000FF");
    public static PlayerColor Green => new("#00FF00");
    public static PlayerColor Yellow => new("#FFFF00");
    public static PlayerColor Purple => new("#800080");
    public static PlayerColor Orange => new("#FFA500");
    
    public static readonly PlayerColor[] AvailableColors = 
    {
        Red, Blue, Green, Yellow, Purple, Orange
    };
    
    public static implicit operator string(PlayerColor color) => color.Value;
    
    public static PlayerColor FromString(string value)
    {
        if (string.IsNullOrWhiteSpace(value))
            throw new ArgumentException("Color value cannot be null or empty", nameof(value));
            
        if (!value.StartsWith("#") || value.Length != 7)
            throw new ArgumentException("Invalid color format. Expected #RRGGBB", nameof(value));
            
        return new PlayerColor(value);
    }
}
